Skip to content

fix(cookbook): stop local Windows download orphans that deadlock HF retries#5720

Open
ZakrepaShe wants to merge 2 commits into
odysseus-dev:devfrom
ZakrepaShe:fix/cookbook-local-windows-stop-orphans
Open

fix(cookbook): stop local Windows download orphans that deadlock HF retries#5720
ZakrepaShe wants to merge 2 commits into
odysseus-dev:devfrom
ZakrepaShe:fix/cookbook-local-windows-stop-orphans

Conversation

@ZakrepaShe

Copy link
Copy Markdown

Summary

On native Windows, Cookbook Stop could kill only the outer session wrapper and leave hf.exe / python.exe children holding HuggingFace cache locks. Retrying the same repo then hung forever on Still waiting to acquire lock… while the UI no longer tracked the orphan. This PR centralizes stop in POST /api/cookbook/stop-session for local Windows, verifies process-tree kills (and session/orphan scans), preserves recovery artifacts when stop fails, writes stop markers only after success, and refuses/reattaches when a same-repo local downloader is already live.

This is the narrow local-Windows stop/orphan/deadlock slice from the closed #3996 effort, rebased onto current dev without remote-Windows, agent-platform, or progress-parser follow-ups.

Target branch

  • This PR targets dev, not main.

Linked Issue

Fixes #3995

Related: #2998 (same cancel-leaves-python-running symptom), #5220 / closed #5219 (narrower related slice that did not merge), supersedes the local-Windows portion of closed #3996.

Type of Change

  • Bug fix (non-breaking — fixes a confirmed issue)

Checklist

How to Test

  1. Native Windows Odysseus with Git Bash available.
  2. Cookbook → download a multi-file HF repo on the local host.
  3. Press Stop while it runs; confirm Task Manager no longer shows hf.exe / python.exe children for that repo.
  4. Press Retry / start the same repo again; it should resume from cache without Still waiting to acquire lock….
  5. Start a download, leave it running, start the same repo again; it should reattach/reuse or refuse rather than launch a second lock contender.
  6. pytest tests/test_cookbook_local_windows_stop.py tests/test_cookbook_download_restart_js.py -q

Out of scope (follow-ups)

Visual / UI changes

Stop failure now surfaces a toast and rolls the live card back instead of falsely marking stopped. No new colors, spacing, fonts, or component patterns.

…etries

Client-side tree-kill alone could leave hf/python children holding cache locks
after Stop. Centralize stop in /api/cookbook/stop-session with verified local
Windows kills, orphan scans, stop markers, and a same-repo live-download guard
so retries reattach or refuse instead of deadlocking.

Co-authored-by: Cursor <cursoragent@cursor.com>
@github-actions github-actions Bot added the ready for review Description complete — ready for maintainer review label Jul 23, 2026
Current dev annotates agent_loop helpers with dict[str, Any] but never
imports Any, so launch-windows.ps1 / uvicorn crashes on import.

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready for review Description complete — ready for maintainer review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: stopping a local Windows cookbook download leaves orphaned hf/python processes that deadlock every retry on the HF cache locks

1 participant